export function dicFormatter(options = [], val) {
  let find = deepFind(options, val)
  return find?.label || val
}

const deepFind = (options, val) => {
  for (let i = 0; i < options.length; i++) {
    let item = options[i]
    if (item.value == val) return item
    if (item.children && item.children.length) {
      let res = deepFind(item.children, val)
      if (res) return res
    }
  }
}

export function matchProjectState(val, options) {
  let find = options.find(item => item.value === val)
  return find
}

export const ProjectFormType = {
  ADD: '添加',
  DETAIL: '详情',
  EDIT: '编辑',
  REVIEW: '审核',
}

export const ProjectListType = {
  LIST: '添加',
  REVIEW_LIST: '审核',
}

export const ApplyApproveType = {
  UPLOAD: '上传文件',
  FORM: '表单',
}

export const stateEnum = {
  WAIT_APPROVAL: '1',
  REJECT: '2',
  PASS: '3',
}

export const stateOptions = [
  {
    label: '待审批',
    value: '1',
  },
  {
    label: '已通过',
    value: '3',
  },
  {
    label: '已驳回',
    value: '2',
  },
]

